package com.insideClass.TypeMessage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

class CountedInteger{
    private static long counter;
    private final long id=counter++;
    @Override
    public String toString() {
        return Long.toString(id);
    }
}

/**
 * @author 13699
 */
public class FilledList<T> {
    private Class<T> type;
    public FilledList(Class<T> type){
        this.type=type;
    }
    public List<T> create(int nElemtes){
        List<T> result=new ArrayList<>();
        try {
            for(int i=0;i<nElemtes;i++) {
                result.add(type.newInstance());
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }

    public static void main(String[] args) {
        FilledList<CountedInteger> fl=new FilledList<>(CountedInteger.class);
        System.out.println(fl.create(15));
    }
}
